using UnityEngine;
using System.Collections;

public class HitDrop : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnCollisionEnter(Collision collisionInfo)
    {
        var hitObject = collisionInfo.gameObject;
        if (hitObject.tag == "Enemy")
        {
            //Debug.Log(hitObject.name);
            hitObject.rigidbody.useGravity = true;
            hitObject.AddComponent<SafeDelete>().delayTime = 0.01f;
            var go = GameObject.Find("genCoin");
            if(go!=null)
                go.SendMessage("HitObject", hitObject);
        }
        var sd = this.GetComponent<SafeDelete>();
        if(sd != null)
            DestroyObject(sd);
    }
}
